import { beforeRequest, afterRequest } from './request'

export default function(routes){
  const route = routes || this.routes
  for(var i = 0; i < route.length; i++){
    const Route = route[i]

    if(Route.beforeRequest)
      beforeRequest.call(this, Route)

    if(Route.afterRequest)
      afterRequest.call(this, Route)

    if(Route.children instanceof Array)
      Route.children = this.createRoute(Route.children)
  }
  return route
}
